(function(){var y,b;try{var n=window.$MicrosoftMaps8,t=n.Internal,ti=n.BasicMapAnimation,wi=t._Binding,bi=t._BoundsAccumulator,c=t._Debug,ki=t._Dispatcher,d=t._Gimme,o=n.GlobalConfig,r=t._Helper,g=n.ImageryMapLayer,nt=t._JSEvent,et=n.LocationRect,ii=t._LruCache,ri=t._MapAuthentication,di=t.MapHelper,gi=n.MapLayer,u=n.Location,e=n.MapMath,l=n.MapTypeId,p=n.MapView,a=n.Matrix2D,rt=t._Network,nr=t._Observable,tr=t._ObservableCollection,ir=t._ObservableObjectChangedArgs,s=n.Point,rr=n.PooledImage,ut=n.Rectangle,ui=n.SimplePointPrimitive,v=n.Size,pt=n.LabelVisibility,ot=n.VectorMapLayer,h=t._VectorMath,i=n.ZoomLevel,fi=t._Url,ur=t.PyramidTileSpatialIndex,ei=n.PyramidTileId,st=t.RasterTileCache,ht=t.RasterTile,fr=t._LatLonCrs,oi=t.TileSystemHelper,si=n.ResourceManager,vt=this&&this.__extends||function(){var n=function(t,i){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r(){this.constructor=t}if(typeof i!="function"&&i!==null)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");n(t,i);t.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}(),k=function(){function t(){}return t.constrainView=function(r,u){var f=!1,o=u.view,c,w,h,a,b,k;(u.cause===0||u.cause===3)&&(c=i.fromLocation(u.view.cameraLocation,!0),c=Math.floor(c),u.view.cameraLocation=i.toLocation(u.view.cameraLocation,c,!0));var l=r.getMode(),e=r.getViewport(),d=r.getViewportPadding(),s,y,p;return s=l.getCurrentCrs(),w=l.getTileSize(),y=w.height,p=w.width,h=r.getMapOptions().navigationOptions.minCameraAltitude,h=typeof h=="number"?Math.max(l.getMinAltitude(),h):l.getMinAltitude(),a=r.getMapOptions().maxBounds,(o.heading===0||s instanceof n.BirdseyeV2Crs)&&(f=f||t.enforceMinZoom(r,u.view),f=f||t._enforceMinAltitude(s,o,e,d,p,y,h),t._checkConstrainBirdseyeV2View(r,s)&&r.getMapOptions().constrainBirdseyeView?f=f||t.constrainBirdseyeV2LatLong(r,s,new v(e.pixelWidth,e.pixelHeight),o):(b=t._enforceLatitudeBoundaries(o,new v(e.pixelWidth,e.pixelHeight),y,a),f=f||b,a&&(k=t._enforceLongitudeBoundaries(o,new v(e.pixelWidth,e.pixelHeight),p,a),f=f||k))),f},t.enforceMinZoom=function(n,r,f){var b=!1,k=n.getMode(),o=n.getViewport(),nt=n.getViewportPadding(),s,c,l,a,g,p,w;s=k.getCurrentCrs();a=k.getTileSize();c=a.height;l=a.width;var tt=n.getMapOptions().navigationOptions.minZoomFraming,d=n.getMapOptions().navigationOptions.maxCameraAltitude,e=0,v=Math.ceil(h.log2(o.pixelWidth/l)),y=Math.ceil(h.log2(o.pixelHeight/c));switch(tt){case 0:e=Math.max(v,y);break;case 1:e=v;break;case 2:e=y;break;case 3:e=Math.min(v,y);break;case-1:e=3}return t._checkConstrainBirdseyeV2View(n,s)&&(g=s.sceneMetadata,e=Math.max(e,t.getBirdseyeV2AdjustedZoom(r.cameraLocation,o,g,n.getMapOptions().constrainBirdseyeView,f))),p=i.toAltitude(new u(0,0),e,!0),w=typeof d=="number"?Math.min(d,p):p,r.cameraLocation.altitude>w&&(t._setCameraAltitude(s,r,o,nt,l,c,w),b=!0),b},t._enforceMinAltitude=function(n,i,r,u,f,e,o){var s=!1;return i.cameraLocation.altitudes?(a=e?e.getNorth():null,o=t._enforceNorthernBoundary(n,r,u,a)):(v=e?e.getSouth():null,o=t._enforceSouthernBoundary(n,r,u,v)):(n.cameraLocation.latitude=s,o=!0),o},t._enforceNorthernBoundary=function(n,t,r,u){var e=!1,h=i.fromLocation(n.cameraLocation,!0),c=t.height/2,o=c/(Math.pow(2,h)*r),s=f.instance.toLatitude(0,typeof u=="number"?o+f.instance.projectToY(u,0):o);return n.cameraLocation.latitude>s&&(n.cameraLocation.latitude=s,e=!0),e},t._enforceSouthernBoundary=function(n,t,r,u){var e=!1,h=i.fromLocation(n.cameraLocation,!0),c=t.height/2,o=c/(Math.pow(2,h)*r),s=f.instance.toLatitude(0,typeof u=="number"?f.instance.projectToY(u,0)-o:1-o);return n.cameraLocation.latitudeo?t._enforceEasternBoundary(n,r,u,f.getEast()):t._enforceWesternBoundary(n,r,u,f.getWest()):(n.cameraLocation.longitude=o,e=!0)}return e},t._enforceEasternBoundary=function(n,t,r,u){var e=!1,s=i.fromLocation(n.cameraLocation,!0),h=t.width/2,c=h/(Math.pow(2,s)*r),o=f.instance.toLongitude(f.instance.projectToX(0,u)-c,0);return n.cameraLocation.longitude>o&&(n.cameraLocation.longitude=o,e=!0),e},t._enforceWesternBoundary=function(n,t,r,u){var e=!1,s=i.fromLocation(n.cameraLocation,!0),h=t.width/2,c=h/(Math.pow(2,s)*r),o=f.instance.toLongitude(f.instance.projectToX(0,u)+c,0);return n.cameraLocation.longitude.36;return l&&e&&(o||!(h<=u.endingZoomLevel&&h>=s))&&(s=Math.min(u.endingZoomLevel,s+1)),s},t.getBirdseyeV2MinZoom=function(n,t,i){var u=18,r,f;return t&&(r=i?Math.round:Math.ceil,f=Math.min(r(h.log2(t.width/n.pixelWidth)),r(h.log2(t.height/n.pixelHeight))),u=t.endingZoomLevel-f+1),u},t.constrainBirdseyeV2LatLong=function(n,t,r,u){var s=!1;if(t.sceneMetadata){var f=t.sceneMetadata,h=i.fromLocation(u.cameraLocation,!0),e=t.projectToX(u.cameraLocation.latitude,u.cameraLocation.longitude),o=t.projectToY(u.cameraLocation.latitude,u.cameraLocation.longitude),c=r.width/(1024*Math.pow(2,h)),l=r.height/(1024*Math.pow(2,h)),a=f.maxTileOffset/Math.pow(2,f.endingZoomLevel),b=(f.maxTileOffset+f.width/512)/Math.pow(2,f.endingZoomLevel),k=(f.maxTileOffset+f.height/512)/Math.pow(2,f.endingZoomLevel),v=a+c,y=b-c,p=a+l,w=k-l;(ey||ow)&&(e=Math.min(Math.max(v,e),y),o=Math.min(Math.max(p,o),w),u.cameraLocation.latitude=t.toLatitude(e,o),u.cameraLocation.longitude=t.toLongitude(e,o),s=!0)}return s},t}(),wt=function(){function n(n,t,i,r,u,f,e,o){var s=this;this._disposables=[];this._dpr=u;this._canvasId=r;n&&(this._canvasFactory=n,o||this._createCanvas());this._currentTransformationOrigin="top left";this._currentOpacity=f?f.getOpacity():1;this.zIndex=i;this._currentPercentOpacity=100;this._imageryMapLayer=f;this._parentElement=t;f&&f.isCritical?f.onCriticalDataLoaded().then(function(){s._isDisposed||s._setupCanvas(e)}):this._setupCanvas(e)}return n.prototype.getRootElement=function(){return this._canvasElement},n.prototype.setPercentOpacity=function(n){n=n>100?100:n;this._canvasElement&&this._currentPercentOpacity!==n&&(this._currentPercentOpacity=n,this._canvasElement.set_style({opacity:n/100*this._currentOpacity}))},n.prototype.getOpacityPercentage=function(){return this._currentPercentOpacity},n.prototype.transformCanvas=function(n,t){var i,u,r;this._canvasElement&&(i=n.getValues(),u="matrix("+i[0]+","+i[1]+","+i[2]+","+i[3]+","+i[4]+","+i[5]+")",this._canvasElement.set_style({"-webkit-transform":u,transform:u}),r=t?"center center":"top left",r!==this._currentTransformationOrigin&&(this._currentTransformationOrigin=r,this._canvasElement.set_style({"-webkit-transform-origin":r,"transform-origin":r})),this._currentTransformationValues=i)},n.prototype.copyCanvas=function(n,t){if(this._currentTransformationValues){var i=this._canvasDrawingContext.getSize(),r=n.getDevicePixelRatio()/this._canvasDrawingContext.getDevicePixelRatio();n.drawImage(this._canvasElement[0],this._currentTransformationValues[4],this._currentTransformationValues[5],i.width*(t?1:this._currentTransformationValues[0])*r,i.height*(t?1:this._currentTransformationValues[3])*r)}},n.prototype.clear=function(){this._canvasDrawingContext&&this._canvasDrawingContext.clear()},n.prototype.dispose=function(){this._isDisposed=!0;r._disposeEvents(this);r._clearDisposables(this._disposables);r._nullifyClass(this)},n.prototype._setupCanvas=function(n){this._canvasElement&&(this._canvasElement.set_style({zIndex:this.zIndex,position:"absolute",left:"0px",opacity:this._currentOpacity,"-webkit-transform-origin":this._currentTransformationOrigin,"transform-origin":this._currentTransformationOrigin}),this._canvasElement.set_attr("Id",this._canvasId),n?this._parentElement.append(this._canvasElement):this._parentElement.fadeIn(this._canvasElement,tt.fadingAnimationDuration,null,this._imageryMapLayer?this._imageryMapLayer.isBaseLayer:!1))},n.prototype._createCanvas=function(){this._canvasFactory&&!this._canvasElement&&(this._disposables.push(this._canvasDrawingContext=this._canvasFactory({devicePixelRatio:this._dpr})),this._canvasElement=this._canvasDrawingContext.getRootElement())},n}(),tt=function(){function n(n,t,i,r){this._disposables=[];this._map=n;this._disableHachHackSetFrame=n.getConfig().disableHachHackSetFrame;this._compositeMapMode=t;this._sortedRenderers=r;this.onPaint=new nt;this._initialize(i)}return n.containsCustomOverlay=function(){n.hasCustomOverlay=!0},n.prototype.onPrimitiveRenderingStart=function(){var n=this;this._initialViewport=this._compositeMapMode.getCurrentCrsViewport();this._sortedRenderers.forEach(function(n){n.setPercentOpacity(100);n.transformCanvas(a.identity)});this._animationCanvasStoryBoard&&this._animationCanvasStoryBoard.seek(1);this._currentOpacity>0&&(this._animationCanvasStoryBoard=d.Effects.Storyboard.create([this._animationDrawingContext.getRootElement()],{value:this._currentOpacity},{value:0},function(t,i){t.set_style({opacity:i.value});n._currentOpacity=i.value;i.value===0&&(n._animationCanvasStoryBoard=null)},300*this._currentOpacity,null,function(){n._animationCanvasStoryBoard=null;n._currentOpacity=0},function(n){return n}),this._animationCanvasStoryBoard.begin())},n.prototype.clear=function(){this._animationDrawingContext.clear(this._getBackgroundColor())},n.prototype.dispose=function(){r._clearDisposables(this._disposables);r._disposeEvents(this);r._nullifyClass(this)},n.prototype._initialize=function(t){var i=this,u,r;this._disposables.push(this._animationDrawingContext=t());u=this._animationDrawingContext.getRootElement();this._currentOpacity=1;u.set_style({zIndex:n._zIndexDuringAnimation,position:"absolute"});r=this._compositeMapMode.getRootElement();u.appendTo(r);r.set_style({"background-color":this._getBackgroundColor()});this._disposables.push(this._map.mapTypeChanged.add(function(){r.set_style({"background-color":i._getBackgroundColor()})}));this._disableHachHackSetFrame?this._disposables.push(this._map.viewChanged.add(function(){return i._onViewChanged()},!0)):(this._disposables.push(this._map.mapPanStopped.add(function(){return i._onPanningStop()},!0)),this._disposables.push(this._map.viewChanged.add(function(){return i._onViewChanged()})));this._disposables.push(this._map.mapPanStarted.add(function(){return i._onPanningStart()}));this._disposables.push(this._map.mapZoomStarted.add(function(){return i._isInPanning=!1}));this._disposables.push(this._map.viewChanging.add(function(n){return i._onViewChanging(n)}));this._map.frameManagerLoaded.addOne(function(){i._onFrameManagerLoaded(i._map.getFrameManager())},!1,!0)},n.prototype._onFrameManagerLoaded=function(n){var t=this;this._previousMapview=this._map.getView();this._disposables.push(n.frameRendered.add(function(){t._onFrameRendered()}));this._disposables.push(n.frameFailed.add(function(n){n.reason===5&&t._onFrameRendered()}));this._disposables.push(n.onDisabled.add(function(){t._disabled=!0;t.clear();t._onFrameDisabled();var i=t._map.getSizeHelper().resize.add(function(){return t._onFrameDisabled()});t._disposables.push(n.frameSet.addOne(function(){t._disabled=!1;i.dispose()}))}))},n.prototype._onFrameDisabled=function(){if(this._map){this._currentOpacity=1;var n=this._map.getActualSize(),t=this._animationDrawingContext.getRootElement();t.set_style({zIndex:25e3,opacity:1,width:n.width,height:n.height,"background-color":this._getBackgroundColor()})}},n.prototype._onFrameRendered=function(){if(this._initialViewport=this._compositeMapMode.getCurrentCrsViewport(),this.isInAnimation=!1,this._updateCurrentCritialLayer()){var u=this._map.getViewport(),f=this._map.getView(),e={pixelHeight:u.pixelHeight*n._viewportSizeRatioForBackgroundTiles,pixelWidth:u.pixelWidth*n._viewportSizeRatioForBackgroundTiles,crs:u.crs,bounds:null},r=[],o=Math.floor(i.fromLocation(f.cameraLocation,!0)),t=o-n._zoomLevelDifferenceForBackgroundTiles;t>0&&r.push(new p(i.toLocation(f.cameraLocation,t,!0)));t>n._highestZoomLevelBackgroundTiles&&(t=n._highestZoomLevelBackgroundTiles,r.push(new p(i.toLocation(f.cameraLocation,t,!0))));r.length>0&&this._currentCriticalLayer.refreshBackgroundTiles(e,r)}},n.prototype._onAnimationStart=function(){var i,t;this._animationStartMapView=this._map.getView();this._animationCanvasStoryBoard&&this._animationCanvasStoryBoard.abort();this._currentOpacity=1;i=this._map.getActualSize();this._animationDrawingContext.setSize(i.width,i.height);this._animationDrawingContext.getRootElement().set_style({opacity:1,zIndex:n._zIndexDuringAnimation});this.clear();t=this._map.getLabelController();this._labelController=t&&t.getIsLabelsSupported()?t:null;this.isInAnimation=!0;this._labelController&&this._labelController.SetAnimationState(this.isInAnimation);this._previousViewport=null;this._updateCurrentCritialLayer()},n.prototype._updateCurrentCritialLayer=function(){for(var n,i=this._map.getAllLayers(),t=0;t0&&(t._animationDrawingContext.setGlobalAlpha(r),i.copyCanvas(t._animationDrawingContext),t._animationDrawingContext.setGlobalAlpha(1)):i.copyCanvas(t._animationDrawingContext,t._currentRotation!==0)}});this._currentRotation!==0&&this._animationDrawingContext.restore();this._previousMapview=this._map.getView();n.hasCustomOverlay||this._labelController&&this._labelController.copyCanvas(this._animationDrawingContext);r.set_style({zIndex:n.hasCustomOverlay?0:25e3,opacity:this._currentOpacity})},n.prototype._getBackgroundColor=function(){return this._map.getMapOptions().backgroundColor||this._map.getMapType().backgroundTileColor},n.prototype._adjustCrsViewport=function(n,t){if(this._animationStartMapView){var e=n.cameraLocation.longitude-this._animationStartMapView.cameraLocation.longitude,i=t.bounds,u=i[1]-this._initialViewport.bounds[1],r=t.crs.bounds[1]-t.crs.bounds[3],f=r/2;e>0?u<-f&&(i[1]+=r,i[3]+=r):u>f&&(i[1]-=r,i[3]-=r)}},n.prototype._render=function(){var e,u,t,i;if(this.isInAnimation){var o=this._map.getViewport(),f=this._map.getView(),n=void 0,r=void 0;if(o.areEqual(this._previousViewport)&&p.areEqual(f,this._previousMapview))return;for(this._currentRotation=(this._previousMapview.heading-f.heading)*Math.PI/180,n=this._compositeMapMode.getCurrentCrsViewport(),this._isInPanning&&this._adjustCrsViewport(f,n),r=this._currentTransformationMatrixInCrs=this._currentRotation===0?this._initialViewport.transform(n):a.identity.rotate(this._currentRotation),e=r.getValues()[0],this._previousViewport=o,u=0;u1&&t instanceof ct&&(i=3/e,i=i<.125?0:i,t.setPercentOpacity(i*100)),t.getOpacityPercentage()>0&&t.transformCanvas(r,this._currentRotation!==0);this._currentRotation===0?this._renderBackgroundTiles():this.clear();this._labelController&&this._labelController.renderLabels(n,!0);this.onPaint.invoke({viewport:n,transformationMatrix:r,percentComplete:1})}},n.prototype._onViewChanging=function(){this._disabled||(this._initialViewport&&!this.isInAnimation&&this._onAnimationStart(),this._render())},n.prototype._renderBackgroundTiles=function(){var u=this,h=this._currentCriticalLayer&&this._currentCriticalLayer.getCurrentCrs();if(h){var n=this._map.getViewport(),t=this._currentTransformationMatrixInCrs.transform({x:0,y:0}),r=this._currentTransformationMatrixInCrs.transform({x:n.pixelWidth,y:n.pixelHeight});if(!this._isInside(0,0,t.x,t.y,r.x,r.y)||!this._isInside(n.pixelWidth,n.pixelHeight,t.x,t.y,r.x,r.y)){var c=this._map.getView(),e=c.cameraLocation,l=new s(h.projectToX(e.latitude,e.longitude),h.projectToY(e.latitude,e.longitude)),a=Math.floor(n.pixelWidth/2),v=Math.floor(n.pixelHeight/2),y=i.fromLocation(e,!0),o=this._currentCriticalLayer.getTileSize(),f=window.devicePixelRatio||1;this._currentCriticalLayer.getAllTilesForAnimation(n,c,this._isInPanning,function(i){var w,b;if(u._animationDrawingContext){var p=i.tileRegion,s=i.requestedRegion,g=y-s.zoom,nt=Math.pow(2,g),e=Math.round(o*nt),k=Math.pow(2,s.zoom),tt=Math.round(e*k*l.x),it=Math.round(e*k*l.y),h=s.x*e-tt+a,c=s.y*e-it+v,d=u._doOverlap(0,0,n.pixelWidth,n.pixelHeight,h,c,h+e,c+e),rt=d&&u._isInside(h,c,t.x,t.y,r.x,r.y)&&u._isInside(h+e,c+e,t.x,t.y,r.x,r.y);d&&!rt&&(i.image?s.zoom===p.zoom?u._animationDrawingContext.drawImage(i.image.image,h,c,e*f,e*f):(w=Math.pow(2,p.zoom-s.zoom),b=o*w*f,u._animationDrawingContext.drawImage(i.image.image,h,c,e*f,e*f,null,(s.x*w-p.x)*o,(s.y*w-p.y)*o,b,b)):u._animationDrawingContext.clear(null,h,c,e*f,e*f))}})}}},n.prototype._isInside=function(n,t,i,r,u,f){return n>=i&&n<=u&&t>=r&&t<=f},n.prototype._doOverlap=function(n,t,i,r,u,f,e,o){return n>e||u>i?!1:t>o||f>r?!1:!0},n.prototype._onPanningStart=function(){var t,n,i;for(this._isInPanning=!0,t=this._map.getAllLayers(),n=0;n0))for(this._setupRender(n,t),this._createCanvasOnDemand(n),o=this._canvasDrawingContext,r=0;r0&&(this._hitTestingData||(this._hitTestingCanvasDrawingContext.setSize(this._currentRegion.pixelWidth,this._currentRegion.pixelHeight),this._hitTestingCanvasDrawingContext.clear(),this._renderInternal(null,!0),this._hitTestingData=this._hitTestingCanvasDrawingContext.getHitTestingData()),this._hitTestingData.setResultToArgs(t.x,t.y,n))},i.prototype._renderInternal=function(n,t){for(var e,l,f,a,r,o,i=t?this._hitTestingCanvasDrawingContext:this._canvasDrawingContext,w=this._vectorEntitiesGL(),v={},s={},y={},h=[],p=0,u=0;u0)){if(t||(this._createCanvasOnDemand(n),i=this._canvasDrawingContext),a=e.getTemplateSelector()||this._templateSelector,!a)continue;if(i&&i.setLayer(e),r=this._renderPrimitives(f,i,a,t,w),!t){if(s[u]=f,r.unhandled.length>0)v[u]=r.unhandled;else{for(o in r.vectorEntities)r.vectorEntities.hasOwnProperty(o)&&(y[o]=r.vectorEntities[o]);h.push.apply(h,r.atlasRecords)}p+=f.length}}return c.enableFunctionalTestHooks&&!t&&c.logVectorRenderingData(this._renderedPrimitivesCount,this._revisionNumber,this._totalCoordinatesCount,this._generalizedCoordinatesCount),i&&(p!==0||t?i.flush():i.clear()),Object.keys(v).length>0?s:this._drawTemplateRenderingResults(s,h,y,t)},i.prototype._renderPrimitives=function(n,i,r,u,f){for(var e,s,l,a,v={},y=[],h=[],c=0;c-1&&this._sortedCurrentVectorLayer.splice(t,1);delete this._currentVectorLayers[n._internalId];this._sortedCurrentVectorLayer.length===0&&this._vectorLayerRenderer&&this._removeRenderer()},n.prototype._removeLayer=function(n,t){var i=this._currentImageryLayers[n]||this._currentVectorLayers[n];i&&(t&&(r._clearDisposables(this._layersEventHandlers[n]),delete this._layersEventHandlers[n]),i instanceof g?(this._removeRenderer(i),delete this._currentImageryLayers[n]):this._tryRemoveVectorLayerRenderer(i))},n.prototype._removeRenderer=function(t){var i;if(t?this._sortedRenderers.forEach(function(n){n instanceof lt&&n.getLayer()===t&&(i=n)}):(this._hitTestController.removeComponent(this._vectorLayerRenderer),i=this._vectorLayerRenderer,this._vectorLayerRenderer=null),this._removeFromSorted(i),t&&t===this._previousBaseImageryLayer&&this._baseImageryLayer)this._previousBaseImageryLayer=null,this._baseImageryLayer.onCriticalDataLoaded().then(function(){i.getRootElement().fadeOut(!0,tt.fadingAnimationDuration,function(){i&&i.dispose()})});else{var f=this._map.viewChanging.addOne(function(){n.disposeRenderer(i)}),r=function(){f.dispose();n.disposeRenderer(i)},u=i.getRootElement();u?u.fadeOut(!0,tt.fadingAnimationDuration,r):r()}},n.prototype._sortRenderers=function(){this._sortedRenderers.sort(function(n,t){return n.zIndex-t.zIndex})},n.prototype._removeFromSorted=function(n){if(n){var t=this._sortedRenderers.indexOf(n);t>-1&&this._sortedRenderers.splice(t,1)}},n.disposeRenderer=function(n){if(n){var t=n.getRootElement();t&&t.removeFromParent();n.dispose()}},n}(),bt=function(){function n(n,t,i,r){if(n<0)throw new Error("Viewport.ctor - pixelWidth cannot be less than zero");if(t<0)throw new Error("Viewport.ctor - pixelHeight cannot be less than zero");this.pixelWidth=n;this.pixelHeight=t;this.bounds=i;this.crs=r;var e=Math.abs((r.bounds[1]-r.bounds[3])/(i[1]-i[3]))*n,o=Math.abs((r.bounds[2]-r.bounds[0])/(i[2]-i[0]))*t,u=(e-n)/2,f=(o-t)/2;this._min_x=-u;this._max_x=n+u;this._min_y=-f;this._max_y=t+f}return n.fromIProjectedRegionId=function(t){return new n(t.pixelWidth,t.pixelHeight,t.bounds,t.crs)},n.prototype.areEqual=function(n){return this===n?!0:n?this.pixelHeight!==n.pixelHeight||this.pixelWidth!==n.pixelWidth||this.bounds[0]!=n.bounds[0]||this.bounds[1]!=n.bounds[1]||this.bounds[2]!=n.bounds[2]||this.bounds[3]!=n.bounds[3]||this.crs.id!==n.crs.id||this.crs.version!==n.crs.version?!1:!0:!1},n.prototype.toCrs=function(){return this.pixelWidth>0&&this.pixelHeight>0?new a((this.bounds[1]-this.bounds[3])/this.pixelWidth,0,0,(this.bounds[2]-this.bounds[0])/this.pixelHeight,this.bounds[3],this.bounds[0]):a.identity},n.prototype.fromCrs=function(){return this.toCrs().invert()},n.prototype.transform=function(n){var t=a.identity;return this.crs.id!==n.crs.id&&(t=n.crs.getMatrix(f.instance).invert().multiply(this.crs.getMatrix(f.instance))),n.fromCrs().multiply(t.multiply(this.toCrs()))},n.prototype.normalize=function(n){return(n.xthis._max_x)&&(n.x=h.wrap(n.x,this._min_x,this._max_x)),n},n.prototype.getRectangle=function(){return ut.fromSides(this._min_x,this._max_x,this._min_y,this._max_y)},n}(),f=function(){function n(){if(n.instance)return n.instance;this.id="Mercator";this.bounds=[0,1,1,0]}return n.prototype.toLatitude=function(t,i){return n._yToLatitude(i)},n.prototype.toLongitude=function(n){return(n-.5)*360},n.prototype.projectToX=function(n,t,i){return i===void 0&&(i=!0),i&&(t=u.normalizeLongitude(t)),t/360+.5},n.prototype.projectToY=function(t){return n._latitudeToY(t)},n.prototype.getScale=function(n){c.assert(n&&n.bounds&&n.bounds.length===4,"Invalid region");var t=Math.abs(n.bounds[1]-n.bounds[3]),r=Math.abs(n.bounds[0]-n.bounds[2]),u=h.log2(1/Math.max(t,r));return i.toScale(null,u,!0)},n.getCenter=function(t){var i=t&&t.center;return i?new u(n._yToLatitude((n._latitudeToY(t.getNorth())+n._latitudeToY(t.getSouth()))/2),i.longitude,i.altitude,i.altitudeReference):null},n.prototype.getMatrix=function(n){if(n.id===this.id)return a.identity;if(n.getMatrix){var t=n.getMatrix(this);if(t)return t.invert()}throw new Error("don't know how to convert from "+this.id+" to "+n.id);},n.getMercatorUnitsPerDegreeOfLatitude=function(t){var r=n._latitudeToY(t),i=Math.exp(Math.PI*(2*r-1));return(i*i+1)/(720*i)},n.getMercatorUnitsPerDegreeOfLongitude=function(){return 1/360},n._yToLatitude=function(n){return 90-2*Math.atan(Math.exp((n*2-1)*Math.PI))*h.degreesPerRadian},n._latitudeToY=function(t){if(t>=n._latitudeLimit)return 0;if(t<=-n._latitudeLimit)return 1;var i=Math.sin(t*h.radiansPerDegree);return.5-Math.log((1+i)/(1-i))*n._invFourPi},n.instance=new n,n._latitudeLimit=85.051128,n._invFourPi=1/(4*Math.PI),n._unitsPerMeterAtEquator=1/e.earthCircumference,n}(),hi=function(){function n(){}return n.pixelXYToLocation=function(t,i,f){var e=n.tileSize*Math.pow(2,f),o=r._clamp(t,0,e-1)/e-.5,s=.5-r._clamp(i,0,e-1)/e,h=90-360*Math.atan(Math.exp(-s*2*Math.PI))/Math.PI,c=360*o;return new u(h,c)},n.latitudeToPixelY=function(t,i){var e=n.tileSize*Math.pow(2,i),u,f;return t=r._clamp(t,n.minLatitude,n.maxLatitude),u=Math.sin(t*Math.PI/180),f=.5-Math.log((1+u)/(1-u))/(4*Math.PI),f*e+.5},n.longitudeToPixelX=function(t,i){var f=n.tileSize*Math.pow(2,i),u;return t=r._clamp(t,n.minLongitude,n.maxLongitude),u=(t+180)/360,u*f+.5},n.locationToPixelXY=function(t,i){return new s(n.longitudeToPixelX(t.longitude,i),n.latitudeToPixelY(t.latitude,i))},n.tileSize=256,n.enhancedBirdEyeTileHeight=180,n.minLatitude=-85.05112878,n.maxLatitude=85.05112878,n.minLongitude=-180,n.maxLongitude=180,n}(),ci=function(){function n(){if(n.instance)return n.instance;this.id="Robinson";this.bounds=[0,1,1,0];this._latitudeLengths=[1,.9986,.9954,.99,.9822,.973,.96,.9427,.9216,.8962,.8679,.835,.7986,.7597,.7186,.6732,.6213,.5722,.5322];this._latitudeOffsets=[0,.062,.124,.186,.248,.31,.372,.434,.4958,.5571,.6176,.6769,.7346,.7903,.8435,.8936,.9394,.9761,1];for(var t=0,i=this._latitudeOffsets.length;t=0?-t:t},n.prototype._getLatitude=function(n){var i,t,r,u,f,e;if(n===.5)return 0;if(i=n<.5,n=Math.abs(n-.5),n>=this._latitudeOffsets[this._latitudeOffsets.length-1])return i?90:-90;for(t=1,r=this._latitudeOffsets.length;t=n||t===r-1)return f=this._latitudeOffsets[t-1],e=(t-1)*5+(n-f)/(u-f)*5,i?e:-e},n.prototype._interpolate=function(n,t){if(n=Math.abs(n),n%5==0)return t[n/5];n=n/5;var i=Math.floor(n),r=t[i],u=t[i+1];return r+(u-r)*(n-i)},n.instance=new n,n}(),ft=function(){function n(){}return n.getMapViewForLocationsInView=function(t,r,f,e,o,s){if(c.assertNotNull(s,"locations"),!s||s.length===0)return new p(new u(0,0,i.toAltitude(new u(0,0),1,!0),0),0);if(s.length===1)return new p(new u(s[0].latitude,s[0].longitude,i.toAltitude(s[0],20,!0),0),0);var h=et.fromLocations(s);return n.getMapViewWithBounds(t,r,f,e,o,h)},n.getMapViewWithBounds=function(t,r,o,h,l,a){c.assertNotNull(t,"crs");c.assertNotNull(l,"viewportPadding");c.assertNotNull(a,"bounds");var w=new s(l.left,l.top),it=new s(h.width-l.right,h.height-l.bottom),rt=it.x-w.x,ut=it.y-w.y,ft=new s(w.x+rt/2,w.y+ut/2),k=a.getNorth(),d=a.getSouth(),v=a.getEast(),b=a.getWest();b>v&&(v+=360);var g=e.greatCircleDistance(a.getNorthwest(),new u(k,v)),nt=e.greatCircleDistance(new u(d,b),a.getSoutheast()),y=null;k>0&&d<0&&(y=e.greatCircleDistance(new u(0,b),new u(0,v)));v-b>180&&(g=e.earthCircumference-g,nt=e.earthCircumference-nt,y!==null&&(y=e.earthCircumference-y));var et=Math.max(g,nt,y||0),ot=e.greatCircleDistance(new u(k,0),new u(d,0)),st=et/rt,ht=ot/ut,ct=Math.max(st,ht),tt=f.getCenter(a),lt=i.fromScale(tt,ct,!1),at=i.toAltitude(tt,lt,!0),vt=n.getCameraForLocationToPoint(t,r,o,h,0,tt,ft,at,0);return new p(vt,0)},n.getCameraForLocationToPoint=function(n,t,r,f,e,o,s,c,l){var y=Math.pow(2,i.fromLocation(new u(o.latitude,o.longitude,c),!0)),p=y*t,w=y*r,b=n.projectToX(o.latitude,o.longitude),k=n.projectToY(o.latitude,o.longitude),a,v;return s=h.rotatePoint(s.x-f.width/2,s.y-f.height/2,-h.degreesToRadians(e)),a=b-s.x/p,v=k-s.y/w,new u(n.toLatitude(a,v),n.toLongitude(a,v),c,l)},n}(),li=function(){function t(n,t,i,r,u){this.allowBoxZoom=!0;var e=u;if(!e||typeof e=="string")switch(e){case"Robinson":u=ci.instance;break;case"Mercator":default:u=f.instance}c.assertNotNull(n,"map");c.assert(u&&u.bounds&&u.bounds.length===4&&u.bounds[0]===0&&u.bounds[1]===1&&u.bounds[2]===1&&u.bounds[3]===0,"Only supports cube based CRSs currently");this._map=n;this._allLayers=t;this._canvasDrawingContextFactory=r;this._hitTestController=i;this._hitTestController.startHitTesting(this._map.getRootElement());this._disposables=[];this.mapModeType=0;this.onFrameRendered=new nt;this.onFrameFailed=new nt;this.onPaint=new nt}return t.prototype.getDisplayName=function(){return this.getCurrentCrs().id},t.prototype.tryPointToLocation=function(n,t){t=t||this._map.getView();var f=this.getCurrentCrs(),r=t.cameraLocation,y=i.fromLocation(r,!0),e=this._map.getActualSize(),p=this.getHeading(),o=new s(f.projectToX(r.latitude,r.longitude),f.projectToY(r.latitude,r.longitude)),c=Math.pow(2,y),l=this.getTileSize(),w=c*l.width,b=c*l.height,k=(n.x-e.width/2)/w,d=(n.y-e.height/2)/b;n=h.rotatePoint(k,d,-h.degreesToRadians(p));var a=o.x+n.x,v=o.y+n.y,g=f.toLatitude(a,v),nt=u.normalizeLongitude(f.toLongitude(a,v));return new u(g,nt)},t.prototype.tryLocationToPoint=function(n,t){var w,b,k,d,l;t=t||this._map.getView();var c=this.getCurrentCrs(),o=t.cameraLocation,g=i.fromLocation(o,!0),nt=this.getHeading(),v=Math.pow(2,g),y=this.getTileSize(),r=v*y.width,tt=v*y.height,a=new s(c.projectToX(o.latitude,o.longitude),c.projectToY(o.latitude,o.longitude)),p=a.x*r,f=(c.projectToX(n.latitude,n.longitude)-a.x)*r,it=(c.projectToY(n.latitude,n.longitude)-a.y)*tt,e=this._map.getActualSize();return p-e.width/2<0&&(w=new s(0,0),b=this.tryPointToLocation(w,t),u.normalizeLongitude(n.longitude)>b.longitude&&(f-=r)),p+e.width/2>r&&(k=new s(e.width,0),d=this.tryPointToLocation(k,t),u.normalizeLongitude(n.longitude)r&&(f>r/2?f-=r:f<-r/2&&(f+=r)),l=h.rotatePoint(f,it,h.degreesToRadians(nt)),l.x+=e.width/2,l.y+=e.height/2,l},t.prototype.getMapViewForLocationsInView=function(n,t,i){var u,f;if(!n)throw"The 'locations' parameter cannot be null or undefined.";var r=this._map.getViewportPadding(),t=t||{},e={left:r.left+(t.left||0),top:r.top+(t.top||0),right:r.right+(t.right||0),bottom:r.bottom+(t.bottom||0)};return i||(u=this._map.getViewport(),c.assertNotNull(u,"viewport"),i=new v(u.pixelWidth,u.pixelHeight)),f=this.getTileSize(),ft.getMapViewForLocationsInView(this.getCurrentCrs(),f.width,f.height,i,e,n)},t.prototype.getMapViewWithBounds=function(n,t){var f,u;if(!n)throw"The 'bounds' parameter cannot be null or undefined.";t=t||{};var i=this._map.getViewportPadding(),e={left:i.left+(t.left||0),top:i.top+(t.top||0),right:i.right+(t.right||0),bottom:i.bottom+(t.bottom||0)},r=this._map.getViewport();return c.assertNotNull(r,"viewport"),f=new v(r.pixelWidth,r.pixelHeight),u=this.getTileSize(),ft.getMapViewWithBounds(this.getCurrentCrs(),u.width,u.height,f,e,n)},t.prototype.getMapViewZoomedAboutLocation=function(n,t,i,r){var u=this.tryLocationToPoint(t,n);return this.getMapViewZoomedAboutLocationAtPoint(n,t,u,i,r)},t.prototype.getMapViewZoomedAboutLocationAtPoint=function(n,t,r,f,o){var l=i.fromLocation(new u(t.latitude,t.longitude,n.cameraLocation.altitude),!0),s=e.roundToInterval(l+f,o),h=this._map.getMapType(),c;return s=Math.min(h.maxZoom,Math.max(s,h.minZoom)),c=this.getCameraForLocationToPoint(t,r,i.toAltitude(null,s,!0),0),new p(c,n.heading)},t.prototype.getCameraForLocationToPoint=function(t,i,r,f,e){var o=this.getCurrentCrs(),a=this.getTileSize(),y=a.width,w=a.height,v=this.getHeading(),s,h,c,l;return v===0&&(s=0,h=0,n.BirdseyeV2Crs&&o instanceof n.BirdseyeV2Crs&&o.sceneMetadata&&(c=o.sceneMetadata.centerLocation,s=c.latitude,h=c.longitude),l=new p(new u(s,h,r,0)),k.enforceMinZoom(this._map,l)&&(r=l.cameraLocation.altitude)),ft.getCameraForLocationToPoint(o,y,w,e?e:this._map.getActualSize(),v,t,i,r,f)},t.prototype.getCurrentCrs=function(){var n=this.getCurrentScenes(!0)[0];return n?n.crs:f.instance},t.prototype.getCurrentCrsViewport=function(){var t=this._map.getView(),r=this._map.getActualSize(),f=this.getTileSize(),c=i.fromLocation(t.cameraLocation,!0),e=Math.pow(2,c),n=this.getCurrentCrs(),u=new s(n.projectToX(t.cameraLocation.latitude,t.cameraLocation.longitude),n.projectToY(t.cameraLocation.latitude,t.cameraLocation.longitude)),l=(n.bounds[1]-n.bounds[3])/(f.width*e),a=(n.bounds[2]-n.bounds[0])/(f.height*e),o=r.width*l/2,h=r.height*a/2,v=[u.y-h,u.x+o,u.y+h,u.x-o];return new bt(r.width,r.height,v,n)},t.prototype.getCurrentScenes=function(n){for(var r,o,e,u=this._map.getView(),t=[],s=i.fromLocation(u.cameraLocation,!0),h=i.toScale(u.cameraLocation,s,!0),f=0,c=this._allLayers.length;f2&&Math.abs(t.y-r.y)>2){t.y0)){for(l=h.length,s=0,c=0;c=0;t--)if(i=r[t],this._pointInRegion(n,i)){u=i.key;break}return u},n.prototype._pointInRegion=function(n,t){var u=t.bounds,i,r;return u.pointInRect(n)?t.shape===1?(i=t.center,r=u.minPoint,(n.x-i.x)*(n.x-i.x)/(i.x-r.x)/(i.x-r.x)+(n.y-i.y)*(n.y-i.y)/(i.y-r.y)/(i.y-r.y)<=1):!0:!1},n}(),dt=function(){function t(n,t,i,u,f,e,o,s,h,c,l,a){a===void 0&&(a=256);this._tileRequestFailedCount=0;this._maxFailureForFailover=10;this._cacheTimeOffset=-1;this._sceneRequetId=0;this._totalTilesCount=0;this._pendingTilesCount=0;this._failedTilesCount=0;this._map=n;this._coreConfig=r._getCoreConfig();this.nativeView=t;this.crs=i;this.imageryId=u;this.copyrightProvider=o;this._tileUrlTemplate=f;this._activeTileTemplate=f;this._tileFeatures=e;this._customMapStyleManager=c;this.downloadTimeOut=l;this._disposables=[];this._useTFEAuthentication=typeof TileSource=="undefined"||!(this instanceof TileSource);this._tileSize=a;this._disposables.push(this.tileUrlTemplateChanged=new nt);this._pendingRequest={};n&&this._subscribeToTileChangeEvents(n,f,s,e,h);this._updateGlobalTileUrlTemplateParam()}return t.prototype.setFrame=function(){this._totalTilesCount=this._pendingTilesCount=this._failedTilesCount=0},t.prototype.getRasterTiles=function(){return this._rasterTiles},t.prototype.getPercentCompleted=function(){return this._totalTilesCount===0?0:(this._totalTilesCount-this._pendingTilesCount)/this._totalTilesCount*100},t.prototype.getPercentFailed=function(){return this._failedTilesCount/this._totalTilesCount*100},t.prototype.getTileSize=function(){return this._tileSize},t.prototype.getAllTiles=function(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y){var k,nt,d,g,tt,p,ut;for(v===void 0&&(v=-1),k=[],nt=0;ntthis._maxFailureForFailover||i)),u=t,u=this._tileUrlContainsXParam?u.replace("{x}",n.x.toString()):u,u=this._tileUrlContainsYParam?u.replace("{y}",n.y.toString()):u,u=this._tileUrlContainsZoomParam?u.replace("{zoom}",n.zoom.toString()):u,u=this._tileUrlContainsQuardkeyParam?u.replace("{quadkey}",f):u,u=this._tileUrlContainsBBoxParam?u.replace("{bbox}",this._getWMSBoundsString(n)):u,u=this._tileUrlContainsSubdomainParam?u.replace("{subdomain}",r._getTileSubDomain(f)):u,u=this._getUpdatedUrlWithCredentials(u,e)):(o=t,u=o(n)),u},t.prototype._getRegions=function(n,t,r,u,f){var c=[],e=r.cameraLocation,o,s,h;n=n*u;t=t*u;var b=Math.log(u)/Math.log(2),l=Math.floor(i.fromLocation(e,!0,this instanceof at?undefined:this._tileSize))+b,a=Math.pow(2,l),k=this.crs.projectToX(e.latitude,e.longitude),d=this.crs.projectToY(e.latitude,e.longitude),v=Math.round(this._tileSize*a*k),y=Math.round(this._tileSize*a*d),p=n/2,w=t/2,g=v-p,nt=y-w,tt=v+p-1,it=y+w-1,rt=Math.floor(g/this._tileSize),ut=Math.floor(nt/this._tileSize),ft=Math.floor(tt/this._tileSize),ot=Math.floor(it/this._tileSize);for(o=rt;o<=ft;o++)for(s=ut;s<=ot;s++)h=new ei(o,s,l,this._tileSize,this._tileSize,this.crs),f?f.intersects(et.fromRegionId(h))&&c.push(h):c.push(h);return c},t.prototype._getTile=function(n,t,i,r,u,f,e,o,s,h){var c=this;return new Promise(function(l){n.networkReqId=rt.downloadImage(t,"raster",function(t){var e=new ht(t,i,r,n.regions[0]);u&&st.addTile(e,f);l(e)},function(t,i){var h,a,v;i!==4&&u&&!f&&(!n.isRetry&&c._useTFEAuthentication?(n.isRetry||c._tileRequestFailedCount++,c._logError(),n.isRetry=!0,h=r):h=r.getParent());h?(a=c._getTileUrl(h,n.tileUrlTemplate,n.isRetry),v=c._getcacheKey(a,n.cacheDuration,h),c._getTile(n,a,v,h,u,f,e,o,s).then(function(n){l(n)})):l(null)},null,e,o,s,h)})},t.prototype._updateTileUrl=function(n){if(typeof n=="string"&&!n.startsWith("data:")){var u=fi.fromString(n),i=this._customMapStyleManager.styleString,t=u.queryStringParameters;if(t){t.st!==i&&(t.st?i?t.st=i:delete t.st:i&&(t.st=i));var f=t.it,e=this._customMapStyleManager.buildingVisible,h=this._customMapStyleManager.flatBuildings;if(f&&(!e||h)){var r=f.split(","),o="BX",s="BF";r=e?r.map(function(n){return n===o?s:n}):r.filter(function(n){return n!==o&&n!==s});t.it=r.join(",")}n=u.toString(!0)}}return n},t.prototype._getcacheKey=function(n,t,i){this._useTFEAuthentication&&(n=n.replace(/&?key=([\w|-]{64})/i,""));var r=n+"_"+i.x+"_"+i.y+"_"+o.tileSourceParam;return t>-1&&(this._cacheTimeOffset<-1&&(this._cacheTimeOffset=Date.now()),r+="_"+(Date.now()-this._cacheTimeOffset)%t),r},t.prototype._subscribeToTileChangeEvents=function(n,t,i,r,u){var f=this;i&&n.labelControllerLoaded.addOne(function(){f._subscribeToLabelControllerLabelsEnabledEvent(n,t,i,r,u)},!1,!0);this._customMapStyleManager&&this._disposables.push(this._customMapStyleManager.changed.add(function(){f._updateGlobalTileUrlTemplateParam()}))},t.prototype._subscribeToLabelControllerLabelsEnabledEvent=function(n,t,i,r,u){var f=this;this._disposables.push(n.getLabelController().changed.add(function(n){n.name==="isLabelsEnabled"&&n.newValue==!1?(f._activeTileTemplate=i,f._tileFeatures=u||r):(f._activeTileTemplate=t,f._tileFeatures=r);f._updateGlobalTileUrlTemplateParam()}))},t.prototype._getWMSBoundsString=function(n){var t=et.fromRegionId(n);return t.getWest()+","+t.getSouth()+","+t.getEast()+","+t.getNorth()},t.prototype._updateGlobalTileUrlTemplateParam=function(){var e=this._tileUrlTemplate,n,u;if(this._tileUrlTemplate=this._activeTileTemplate,typeof this._tileUrlTemplate=="string"){n=this._tileUrlTemplate;n=n.replace("{it}",this._tileFeatures).replace("{it2}",this._tileFeatures);var f=this._coreConfig.terrainShadingWithWebp,t=n.indexOf("{shading}")>-1,i=!1;this._customMapStyleManager&&(n=this._updateTileUrl(n),i=t&&this._customMapStyleManager.settingHasValue("shadedReliefVisible",!1));t&&(n=n.replace("{shading}",i?"flat":f?"t":"hill"));u=f&&t&&!i&&d.Browser.is_WebpSupported;n.indexOf("{imageFormat}")>-1?n=n.replace("{imageFormat}",u?"webp,95":"jpeg,95"):u&&(n+="&o=webp");n=n.replace("{synthviewgenid}",o.dynamicProperties.synthViewGenerationId);n=r._updateTfeMktAndUrl(n);this._tileUrlContainsXParam=n.indexOf("{x}")>-1;this._tileUrlContainsYParam=n.indexOf("{y}")>-1;this._tileUrlContainsZoomParam=n.indexOf("{zoom}")>-1;this._tileUrlContainsCredentialsParam=n.indexOf("{credentials}")>-1;this._tileUrlContainsQuardkeyParam=n.indexOf("{quadkey}")>-1;this._tileUrlContainsBBoxParam=n.indexOf("{bbox}")>-1;this._tileUrlContainsSubdomainParam=n.indexOf("{subdomain}")>-1;typeof FunctionalTestHooks!="undefined"&&(this._tileUrlContainsXParam=this._tileUrlContainsYParam=this._tileUrlContainsZoomParam=this._tileUrlContainsCredentialsParam=this._tileUrlContainsQuardkeyParam=this._tileUrlContainsBBoxParam=this._tileUrlContainsSubdomainParam=!0);this._tileUrlTemplate=n;e!==n&&this.tileUrlTemplateChanged.invoke(this)}},t.prototype._getTileUrlTemplate=function(n){var t=this._tileUrlTemplate;return typeof t=="string"&&n&&(t=this._updateUrlForLiteModeBackgroundTile(t)),t},t.prototype._updateUrlForLiteModeBackgroundTile=function(n){var t,i;if(typeof n=="string"){if(t=n,i=t.indexOf("it="),i>-1){i+=3;var r=t.indexOf("&",i),f=t.substr(i,r>-1?r-i:t.length-i).split(","),u=[];f.forEach(function(n){n.toUpperCase()!=="LA"&&n.toUpperCase()!=="L"&&u.push(n)});t=t.substr(0,i)+u.join(",")+(r>-1?t.substr(r):"")}return t}return n},t.prototype._tryAndReturnBackgroundTile=function(n,t,i,r,u,f){var e,o,s,c,h;if(this._backgroundTilesCache=this._backgroundTilesCache||{},e=this._backgroundTilesCache[n],e)f(e);else if(e!==null){for(o=t,s=void 0,r&&(i=this._updateUrlForLiteModeBackgroundTile(i));o.zoom>1;)if(o=o.getParent(),c=this._getTileUrl(o,i,!1),h=this._getcacheKey(c,u,o),s=st.getBackgroundTile(h,r),s){e=new ht(s.image,h,o,t);this._backgroundTilesCache[n]=e;f(e);break}s||(this._backgroundTilesCache[n]=null,f(new ht(null,n,t)))}},t.prototype._processTileResponse=function(n,t){var i=this;n.then(function(n){var r=i._pendingRequest[t];r&&(--r.count<=0&&delete i._pendingRequest[t],r.isBackgroundRequest||r.sceneRequetId!==i._sceneRequetId||(r.isAnimationRequest||i._pendingTilesCount--,c.assert(i._pendingTilesCount>=0,"Can't have less than 0 pending tiles"),n?(n&&i._rasterTiles.push(n),r.callback&&r.callback(n)):r.isAnimationRequest||(i._failedTilesCount++,r.callback&&r.callback(n))))})},t.prototype._logError=function(){var t,i;this._tileRequestFailedCount===this._maxFailureForFailover+1&&Math.random()<=.1&&(t=n.logger,t&&(i={feature:"MC",action:"ERR",data:{errorMessage:"Tile requests failed "+this._tileRequestFailedCount+" times. Switching over to use TFE authentication."}},t.logCriticalError(null,i)))},t.prototype._getUpdatedUrlWithCredentials=function(n,t){return t?this._tileUrlContainsCredentialsParam||(n+="&key="+ri.instance.getSessionId()):!t&&this._tileUrlContainsCredentialsParam&&(n=n.replace(/&?key={credentials}/ig,"")),n},t}();n.CompositeMapMode=li;n.EnhancedBirdseyeCrs=vi;n.MercatorCubeCrs=f;t._VectorLayerRenderer=ct;t._MercatorTileUtility=hi;t.RegionIndex=kt;t.HitTestIndex=pi;t.HitTestController=yi;t._LayerRendererManager=typeof yt!="undefined"?yt:null;t._AnimationRenderer=typeof tt!="undefined"?tt:null;t._BoundaryHelper=k;n.RasterImageryScene=dt;n.Viewport=bt;var n=window.$MicrosoftMaps8,t=n.Internal,ti=n.BasicMapAnimation,wi=t._Binding,k=t._BoundaryHelper,bi=t._BoundsAccumulator,c=t._Debug,ki=t._Dispatcher,d=t._Gimme,o=n.GlobalConfig,r=t._Helper,g=n.ImageryMapLayer,nt=t._JSEvent,et=n.LocationRect,ii=t._LruCache,ri=t._MapAuthentication,di=t.MapHelper,gi=n.MapLayer,u=n.Location,e=n.MapMath,l=n.MapTypeId,p=n.MapView,a=n.Matrix2D,f=n.MercatorCubeCrs,rt=t._Network,nr=t._Observable,tr=t._ObservableCollection,ir=t._ObservableObjectChangedArgs,s=n.Point,rr=n.PooledImage,ut=n.Rectangle,ui=n.SimplePointPrimitive,v=n.Size,pt=n.LabelVisibility,ot=n.VectorMapLayer,h=t._VectorMath,i=n.ZoomLevel,fi=t._Url,ur=t.PyramidTileSpatialIndex,ei=n.PyramidTileId,st=t.RasterTileCache,ht=t.RasterTile,fr=t._LatLonCrs,oi=t.TileSystemHelper,si=n.ResourceManager,dt=n.RasterImageryScene,vt=this&&this.__extends||function(){var n=function(t,i){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r(){this.constructor=t}if(typeof i!="function"&&i!==null)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");n(t,i);t.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}(),it=function(){function n(n,t,i){this._queryLatLongRange=.1;this._unconstrainedViewPaddingRatio=.15;this._locationUpdatedPrecision=1e-6;this._locationQueriedPrecision=.0001;this._sceneMetadataUrl=r._updateTfeUrlDomain(t);this.id="BirdseyeV2_"+n.toString();this.bounds=[0,1,1,0];this.heading=n;i&&(this._unconstrainedViewPaddingRatio=Math.max(Math.min(i,.5),0));var f=r._getUrlParam(window.location,"bev2transitionpadding"),u=f&&parseFloat(f);typeof u!="number"||isNaN(u)||(this._unconstrainedViewPaddingRatio=Math.max(Math.min(u,.5),0))}return n.prototype.toLatitude=function(n,t){var i,r,u;return this.sceneMetadata?(r=(n*Math.pow(2,this.sceneMetadata.endingZoomLevel)-this.sceneMetadata.maxTileOffset)*512,u=(t*Math.pow(2,this.sceneMetadata.endingZoomLevel)-this.sceneMetadata.maxTileOffset)*512,i=this.sceneMetadata.projectToLatLong(r,u)[0]):i=f.instance.toLatitude(n,t),Math.min(Math.max(i,-90),90)},n.prototype.toLongitude=function(n,t){var i,r,u;return this.sceneMetadata?(r=(n*Math.pow(2,this.sceneMetadata.endingZoomLevel)-this.sceneMetadata.maxTileOffset)*512,u=(t*Math.pow(2,this.sceneMetadata.endingZoomLevel)-this.sceneMetadata.maxTileOffset)*512,i=this.sceneMetadata.projectToLatLong(r,u)[1]):i=f.instance.toLongitude(n,t),i},n.prototype.projectToX=function(n,t){var i,r;return this.sceneMetadata?(r=this.sceneMetadata.projectToXY(n,t)[0],i=(r+this.sceneMetadata.maxTileOffset*512)/(512*Math.pow(2,this.sceneMetadata.endingZoomLevel))):i=f.instance.projectToX(n,t),i},n.prototype.projectToY=function(n,t){var i,r;return this.sceneMetadata?(r=this.sceneMetadata.projectToXY(n,t)[1],i=(r+this.sceneMetadata.maxTileOffset*512)/(512*Math.pow(2,this.sceneMetadata.endingZoomLevel))):i=f.instance.projectToY(n,t),i},n.prototype.getMatrix=function(n){var t=a.identity,i=Math.round(h.wrap(this.heading-(n.heading||0),0,360));return t.rotate(i*Math.PI/180)},n.prototype.getScale=function(n){var t,i;return this.sceneMetadata?(i=n.zoom,t=this.sceneMetadata.minScale*Math.pow(2,this.sceneMetadata.endingZoomLevel-i)):t=f.instance.getScale(n),t},n.prototype.update=function(n,t,i,r,u){var f=n.getView().cameraLocation,e=n.getViewport(),o=!1,s=n.getMapOptions().constrainBirdseyeView,c=s&&this._getSceneBoundaryHitArgs(e,f),h={originalMetadata:this.sceneMetadata,viewport:e,constrainView:s,boundaryHitArgs:c};this._shouldUpdateScene(f,n.isPanning(),h)&&(o=!0,this.updateLocation(f,h,t,i,r,u));!o&&i&&i()},n.prototype.updateLocation=function(t,i,r,f,e,o){var h=i.boundaryHitArgs&&i.boundaryHitArgs.transformedCheckLocation||t,s=this._selectSceneFromCache(t,i);s?(this._deletePendingMetadataCall(),this._prevSceneMetadata=this.sceneMetadata,this.sceneMetadata=s,this.version=this.sceneMetadata.sceneId.toString(),this._lastUpdatedLocation=t,r&&r()):u.areEqual(n.lastQueriedLocation,h,!0,this._locationQueriedPrecision)?e&&e():this._requestNewScenes(t,i,r,f,e,o)},n.prototype.getPreviousCrs=function(){var t=new n(this.heading,this._sceneMetadataUrl);return t.sceneMetadata=this._prevSceneMetadata,t.version=this._prevSceneMetadata&&this._prevSceneMetadata.sceneId.toString(),t},n.prototype.getEffectiveZoomForTransition=function(n){var t=i.fromLocation(n,!0);return this.sceneMetadata&&(t+=b.getDeltaZoomBetweenScenes(this._prevSceneMetadata,this.sceneMetadata),this.metadataBeforeRotation&&(t+=b.getDeltaZoomBetweenScenes(this.metadataBeforeRotation,this.sceneMetadata),this.metadataBeforeRotation=null),t=Math.max(Math.min(t,this.sceneMetadata.endingZoomLevel),18)),t},n.prototype.getThumbnailSceneFromCache=function(t,i){for(var r,h=null,c=null,l=n.metadataCache.getInternalDictionary(),a=Object.keys(l),v=Number.MAX_VALUE,y=0,f=0;f0&&e+u>u*Math.ceil(r.maxNumXTiles/s),b=r.height%u>0&&o+u>u*Math.ceil(r.maxNumYTiles/s),k=w||b,d=Math.pow(Math.abs(u/2-e%u),2)+Math.pow(Math.abs(u/2-o%u),2),g=Math.pow(w?r.width-e:u,2)+Math.pow(b?r.height-o:u,2);!k&&dy&&(y=g,c=r)}return h||c},n.prototype.reset=function(){this.sceneMetadata=null;this._prevSceneMetadata=null;this._lastUpdatedLocation=null},n.prototype._deletePendingMetadataCall=function(){var n=this._requestId;this._requestId=null;n&&rt.abortRequest(n);this._sceneSelectionArgs=null},n.prototype._selectSceneFromCache=function(t,r){var l=this,s=[],f=[],h=[],a=.02,v=.05,y=i.fromLocation(t,!0),e=r.originalMetadata||this.metadataBeforeRotation,c=n.metadataCache.getInternalDictionary(),p=Object.keys(c),o=[];p.forEach(function(n){var i=c[n].item;l._isCachedSceneValid(t,i,r)&&o.push(i)});o=this._filterScenesByProvider(o);o.forEach(function(t){if(e){var i=b.getDeltaZoomBetweenScenes(e,t),u=y+i,o=k.getBirdseyeV2MinZoom(r.viewport,t,!1);u>=o&&u<=t.endingZoomLevel&&i<0?s.push(t):Math.abs(e.minScale-t.minScale)0||d?s:f.length>0?f:h;return this._selectMaxPannableScene(t,g,r)},n.prototype._requestNewScenes=function(t,i,r,u,f,e){var s=this,h=i.boundaryHitArgs&&i.boundaryHitArgs.transformedCheckLocation||t,l=h.latitude,a=h.longitude,v=l+this._queryLatLongRange,y=l-this._queryLatLongRange,p=a+this._queryLatLongRange,w=a-this._queryLatLongRange;this._deletePendingMetadataCall();var k=this._sceneMetadataUrl.replace("{subdomain}",Math.floor(Math.random()*4).toString()).replace("{genId}",o.dynamicProperties.birdseyeV2MetadataGenerationId).replace("{north}",v.toString()).replace("{south}",y.toString()).replace("{east}",p.toString()).replace("{west}",w.toString()),c,d=function(i){var e,o;if(i.length>1){for(e=i.length-1;e>0;e--)o=new b(i[e]),n.metadataCache.addItem(o.sceneId.toString(),o);s._calculateAvgCachedMinScale();n.lastQueriedLocation=h;s._postSceneDownload(t,h,c,r,u,f)}else c===s._requestId&&f&&f()},g=function(){c===s._requestId&&(s._deletePendingMetadataCall(),e&&e())};this._requestId=c=rt.downloadJson(k,"birdseyeV2Metadata",d,g,null,null,null,!1);this._sceneSelectionArgs=i},n.prototype._postSceneDownload=function(n,t,i,r,u,f){if(i===this._requestId){var e=this._selectSceneFromCache(n,this._sceneSelectionArgs);this._deletePendingMetadataCall();e&&(!this.sceneMetadata||e.sceneId!==this.sceneMetadata.sceneId)?(this._prevSceneMetadata=this.sceneMetadata,this.sceneMetadata=e,this.version=this.sceneMetadata.sceneId.toString(),r&&r()):e?u&&u():f&&f()}},n.prototype._selectMaxPannableScene=function(n,t,i){var c=null,u=i.boundaryHitArgs,l,e,f,a,v;if(!i.constrainView||u.top&&u.right&&u.bottom&&u.left){for(l=Number.MAX_VALUE,e=null,f=0;fa&&(a=v,e=r);c=e}return c},n.prototype._canPositionLocationInNewScene=function(n,t,r,u,f){var s=r.projectToXY(n.latitude,n.longitude),e=i.fromLocation(n,!0);e=e+b.getDeltaZoomBetweenScenes(t,r);e=Math.max(Math.min(e,r.endingZoomLevel),k.getBirdseyeV2MinZoom(u,r,!1));var h=Math.pow(2,r.endingZoomLevel-e),o=f?0:this._unconstrainedViewPaddingRatio;return r.canCoverViewportWithLocation(n,f,u,o,e)},n.prototype._shouldUpdateScene=function(n,t,r){var e=!1,o=r.constrainView,f=r.boundaryHitArgs;return t||u.areEqual(n,this._lastUpdatedLocation,!0,this._locationUpdatedPrecision)||(e=o?f.top||f.bottom||f.left||f.right:!this.sceneMetadata||!this.sceneMetadata.canCoverViewportWithLocation(n,o,r.viewport,this._unconstrainedViewPaddingRatio,i.fromLocation(n,!0))),e},n.prototype._isCachedSceneValid=function(t,r,u){var e=u.originalMetadata,o=u.boundaryHitArgs,l=u.constrainView,v=u.viewport,f=r.cLook===this.heading,a;if(f&&(a=e||this.metadataBeforeRotation,f=a?this._canPositionLocationInNewScene(t,a,r,v,l):r.canCoverViewportWithLocation(t,l,v,this._unconstrainedViewPaddingRatio)),f&&e&&l){var y=i.fromLocation(t,!0),p=Math.pow(2,this.sceneMetadata.endingZoomLevel-y),s=n.boundaryCheckThreshold*p,h=e.projectToXY(t.latitude,t.longitude),c=r.projectToXY(t.latitude,t.longitude);f&&o.left?f=c[0]-h[0]>s:f&&o.right&&(f=r.width-c[0]-(e.width-h[0])>s);f&&o.top?f=c[1]-h[1]>s:f&&o.bottom&&(f=r.height-c[1]-(e.height-h[1])>s)}return f},n.prototype._filterScenesByProvider=function(n){var t=n.filter(function(n){return n.productId==="236"});return t.length>0?t:n},n.prototype._calculateAvgCachedMinScale=function(){for(var r=n.metadataCache.getInternalDictionary(),t=Object.keys(r),u=0,i=0;i=18){var e=Math.pow(2,r.endingZoomLevel-f),s=Math.ceil(r.maxNumXTiles/e),h=Math.ceil(r.maxNumYTiles/e),y=Math.pow(2,f-17),u=Math.ceil((Math.pow(2,f)-y)/2),c=i.x,l=i.y;c>=u&&c=u&&l>=1,t>>=1;return r},t.prototype._instantiateBorderReplacementImage=function(){if(!t._borderReplacementImage){var n=document.createElement("img"),i=function(i){i&&(n.onload=null,window.clearTimeout(t._brImageTimeoutId),t._brImageTimeoutId=null,t._borderReplacementImage=n)};t._brImageTimeoutId||(t._brImageTimeoutId=Microsoft.Maps.setTimeout(function(){return i(!1)},5e3),n.onload=function(){i(!0)},n.src=this._placeholderTileUrl)}},t._tileSize=512,t._borderReplacementImage=null,t}(dt),gt=function(){function t(n){var t=this;this._map=n;this._disposables=[];this._disposables.push(this._map.mapTypeChanged.add(function(n){t.onMapTypeChanged(n)}));(o.isMapsVertical||o.isMapsAnswer)&&this._disposables.push(this._map.getLayers().changed.add(function(n){t._map.getMapType().id===l.birdseyeV2&&n.added&&n.added.length>0&&t._hideMapLayers()}));this._activated=!1;this._tempHiddenLayers=[];this.previousMapState={mapTypeId:null,altitude:null,birdseyeV2Heading:null}}return t.prototype.dispose=function(){it.lastQueriedLocation=null;it.metadataCache.clear();this._savedTransientLensActionList=null;r._clearDisposables(this._disposables);this._tempHiddenLayers=[]},t.prototype.onMapTypeChanged=function(n){n.newMapTypeId===l.birdseyeV2?this._onActivated(n.oldMapTypeId):n.oldMapTypeId===l.birdseyeV2&&this._onDeactivated(n.newMapTypeId)},t.prototype.addContextPoi=function(n,i,r){var u=this,o={id:"BirdseyeV2ContextPoi",title:i,collisionBehavior:2},f=new ui(n,o),e;f.bucket="999998";f.taskDisplayState={activationState:1,colorIndex:r,prominence:1};f.viewState=2;this._contextLayer?(e=this._contextLayer.getDataSource(),e.clear(),f.layer=this._contextLayer,e.addPrimitive(f),this._map.getLayers().indexOf(this._contextLayer)<0&&this._map.getLayers().insert(this._contextLayer)):this._map.getContainer().instanceAsync("ListDataSource",function(n){n.addPrimitive(f);u._map.getContainer().instanceAsync("XsrPoiTemplateSelector",function(i){u._map.getLayers().remove(u._contextLayer);u._contextLayer=new ot(t._contextLayerId,n,i,1e4);u._contextLayer.setRenderTarget(1);f.layer=u._contextLayer;u._map.getLayers().insert(u._contextLayer)})})},t.prototype._onActivated=function(t){var i=this,u;this._activated||(this._activated=!0,this._lastProductId=null,u=this._map.getView(),t!==l.streetside&&(this.previousMapState.mapTypeId=t,this.previousMapState.altitude=u.cameraLocation.altitude,this._map.navigationBarLoaded.addOne(function(){if(i._map.getMapType().id===l.birdseyeV2){var n=i._map.getNavigationBar().getHelper();n.updateNavBarForBirdseyeV2(!0);t!==null&&n.handleLabelsVisibleOnMapTypeChanged()}},!1,!0),o.isMapsVertical&&(this._map.getContainer().instanceAsync("TransientLens",function(t){if(i._map.getMapType().id===l.birdseyeV2){i._savedTransientLensActionList=t.getViewModel().actionList;var r=n&&n.Internal&&n.Internal.TransientLensActions;r&&(t.getViewModel().actionList=[r.Streetside])}}),this._map.getContainer().instanceAsync("TaskBar",function(n){if(i._map.getMapType().id===l.birdseyeV2){var t=n.fullScreenEnabled?256:0;n.setActionsOptions(8|t)}}),d(".MicrosoftMap .taskLayoutContainer").add_class("hideTaskLayout"),d(".toggleButton").add_class("hideTaskLayout"),this._hideMapLayers(),sj_evt.fire("HideContextualTaskbar")),o.isMapsAnswer&&r._showOrHideOverlayMenu(!1)))},t.prototype._onDeactivated=function(n){var f=this,u,e;this._activated&&(t.approxAltitude=null,u=this._map.getView(),n!==l.streetside?(this.previousMapState.altitude?u.cameraLocation.altitude=this.previousMapState.altitude:(e=i.toLocation(u.cameraLocation,this._map.getMercatorZoomLevel()-1,!0),u=new p(e,0)),this._map.setView(u,null,0,!0),this._map.navigationBarLoaded.addOne(function(){f._map.getNavigationBar().getHelper().updateNavBarForBirdseyeV2(!1)},!1,!0),o.isMapsVertical&&(this._savedTransientLensActionList&&this._map.getContainer().instanceAsync("TransientLens",function(n){n.getViewModel().actionList=f._savedTransientLensActionList}),this._map.getContainer().instanceAsync("TaskBar",function(t){var i=t.fullScreenEnabled?256:0;t.setActionsOptions(n===l.streetside?24|i:2047)}),d(".MicrosoftMap .taskLayoutContainer").remove_class("hideTaskLayout"),d(".toggleButton").remove_class("hideTaskLayout"),this._showMapLayers(),this._map.getLayers().remove(this._contextLayer),r._getIsSlideCardEnabled()?sj_evt.fire("ShowContextualTaskbar"):sj_evt.fire("BirdsEyeDeactivated")),o.isMapsAnswer&&this.previousMapState.mapTypeId!==l.streetside&&r._showOrHideOverlayMenu(!0)):this.previousMapState.birdseyeV2Heading=u.heading,this._activated=!1)},t.prototype.onCrsUpdate=function(n,i){var r=n.getCurrentCrs(),u,f;i===2?this._onCrsUpdateFailed(r):i===1?t.constrainViewOnUpdateCrs(this._map,r,!!r.metadataBeforeRotation):(t.updateApproxAltitude(this._map.getView().cameraLocation,r),t.constrainViewOnUpdateCrs(this._map,r,!0),this._map.copyrightChanged.invoke(),u=this._map.getNavigationBar(),f=u&&u.getHelper(),f&&f.updateLabelToggleForBirdseyeV2(null,!0))},t.prototype._onCrsUpdateFailed=function(n){var r=this,u=n.sceneMetadata,t,i;u?u.isLocationInsideScene(this._map.getView().cameraLocation)||(t=this._map.getNavigationBar(),i=t&&t.getHelper(),i&&i.showBirdseyeV2NotAvailableTip(!1)):this._map.getBirdseyeV2Manager().then(function(n){var t=r._map.getMapTypes()[n.previousMapState.mapTypeId||l.road];t&&r._map.setBaseLayers(t)})},t.prototype._hideMapLayers=function(){for(var n,r=this._map.getLayers(),i=r.length-1;i>=0;i--)n=r[i],n instanceof ot&&n.getId()!==t._contextLayerId&&(this._map.getLayers().remove(n),this._tempHiddenLayers.indexOf(n)<0&&this._tempHiddenLayers.push(n))},t.prototype._showMapLayers=function(){for(var t,n=this._tempHiddenLayers.length-1;n>=0;n--)t=this._tempHiddenLayers[n],t.getFrameManager()&&this._map.getLayers().indexOf(t)<0&&this._map.getLayers().insert(t);this._tempHiddenLayers=[]},t.prototype.getUpdatedProductId=function(n){var t=null,i=n.sceneMetadata;return i&&i.productId!==this._lastProductId&&(t=i.productId,this._lastProductId=t),t},t.hideLayersForSDKMap=function(n){for(var t,u,r=n.hiddenLayerArgsInBEv2||[],f=Microsoft.Maps.TileLayer,e=Microsoft.Maps.DataBinningLayer,o=Microsoft.Maps.CustomOverlay,i=n.layers.length-1;i>=0;i--)t=n.layers[i],o&&t instanceof o&&!t.getOptions().showInBirdseye?(u=t.getAnimationState&&t.getAnimationState(),u===1&&t.pause&&t.pause(),r.push({layer:t,index:i,animationState:u}),n.layers.remove(t)):(f&&t instanceof f||e&&t instanceof e)&&t.getVisible()&&(r.push({layer:t,index:-1}),t.setVisible(!1));n.hiddenLayerArgsInBEv2=r},t.showLayersForSDKMap=function(n){for(var i=n.hiddenLayerArgsInBEv2||[],r=function(t){var r=i[t],u=r.index,f,e;u>=0?(f=n.layers.length,e=u>f?f:u,Microsoft.Maps.setTimeout(function(){n.layers.insert(r.layer,e);r.animationState===1&&r.layer.play()},1)):r.layer.setVisible(!0)},t=i.length-1;t>=0;t--)r(t);n.hiddenLayerArgsInBEv2=null},t.hideSDKLayersDuringTransition=function(n){var u=n.getLayers(),f=Microsoft.Maps.Layer,r=[],i,t;if(f)for(i=0;i0&&n.birdseyeV2SceneTransitioned.addOne(function(){r.forEach(function(n){n.setVisible(!0)})})},t.updateApproxAltitude=function(n,i){var r=[],u=[],s=function(t){for(var f,e,i,s,h,l=[t.topLeftCorner,t.topRightCorner,t.bottomLeftCorner,t.bottomRightCorner],o=0,c=l;o0||i===r.length-1)&&(h=i===r.length-1&&s>e?i+1:i,r.splice(h,0,e),u.splice(h,0,f.altitude),r.length>4&&(r.splice(0,1),u.splice(0,1)));break}},f=it.metadataCache.getInternalDictionary(),h=Object.keys(f),e,o;h.forEach(function(n){var t=f[n].item;i.sceneMetadata&&t.productId!==i.sceneMetadata.productId||s(t)});e=u.reduce(function(n,t){return n+t},0);o=e/u.length;t.approxAltitude=o},t.constrainViewOnUpdateCrs=function(n,t,r){var e=n.getViewport(),f=n.getView(),u=f.cameraLocation,o=u.altitude;r&&(u.altitude=i.toAltitude(u,t.getEffectiveZoomForTransition(u),!0));(k.enforceMinZoom(n,f,!0)||o!==u.altitude)&&n.mapZoomChanged.invoke();n.getMapOptions().constrainBirdseyeView&&k.constrainBirdseyeV2LatLong(n,t,new v(e.pixelWidth,e.pixelHeight),f)},t.getIsBirdseyeV2Available=function(n,t,i,r,u){if(n.birdseyeV2MetadataUrl){var f=b.normalizeHeading(i),e=new it(f,n.birdseyeV2MetadataUrl),o={originalMetadata:null,viewport:u,constrainView:!1,boundaryHitArgs:{top:!0,bottom:!0,left:!0,right:!0}};e.updateLocation(t,o,function(){r&&r(!0)},function(){r&&r(!1)},function(){r&&r(!1)},function(){r&&r(!1)})}else r&&r(!1)},t.getBirdseyeV2Thumbnail=function(n,i,r,u,f,e){var o=null,s;n.birdseyeV2MetadataUrl?(s=b.normalizeHeading(f),t.getIsBirdseyeV2Available(n,i,s,function(f){var a,e,h,c,v;f&&(a=new it(s,n.birdseyeV2MetadataUrl),e=n.mapTypeDefinitions.filter(function(n){return n.mapType===l.birdseyeV2}),e.length>0&&e[0].data&&e[0].data[0]&&(h=e[0].data[0],c=h.imageryScenes&&h.imageryScenes.length>0&&h.imageryScenes[0],c&&(v=a.getThumbnailSceneFromCache(i,r),o=t._getThumbnailUrl(i,v,r,c))));u&&u(o)},e)):u&&u(o)},t._getThumbnailUrl=function(n,t,i,u){var a=null,s,f,h;if(t){var v=t.projectToXY(n.latitude,n.longitude),y=Math.max(Math.min(v[0],t.width),0),p=Math.max(Math.min(v[1],t.height),0),c=Math.max(Math.min(t.endingZoomLevel,i),18),l=512*Math.pow(2,t.endingZoomLevel-c),e=Math.floor(y/l);e===Math.ceil(t.width/l)-1&&t.width%l!=0&&(e=Math.max(e-1,0));s=512*Math.pow(2,t.endingZoomLevel-c);f=Math.floor(p/s);f===Math.ceil(t.height/s)-1&&t.height%s!=0&&(f=Math.max(f-1,0));h=at.positionToQuadkey(e,f,c);a=r._updateTfeUrlDomain(u.tileUrlWithoutLabel).replace("{subdomain}",h.charAt(h.length-1)).replace("{tileUrlParam}",u.tileUrlParam).replace("{tileUrlWithoutLabelParam}",u.tileUrlWithoutLabelParam).replace("{beGenId}",o.dynamicProperties.birdseyeV2ImageryGenerationId).replace("{base4SceneId}",t.base4SceneId).replace("{birdseyeV2Quadkey}",h)}return a},t._contextLayerId="BirdseyeV2ContextLayer",t}(),w;(function(n){n[n.north=0]="north";n[n.east=90]="east";n[n.south=180]="south";n[n.west=270]="west";n[n.North=0]="North";n[n.East=90]="East";n[n.South=180]="South";n[n.West=270]="West"})(w||(w={})),function(n){n[n.V1=0]="V1";n[n.V2=1]="V2"}(y||(y={}));b=function(){function n(n){this.cameraLocation=new u(0,0,0);this.width=0;this.height=0;this.originalWidth=0;this.originalHeight=0;this.imageScaleFactor=1;this.topLeftCorner=new u(0,0,0);this.topRightCorner=new u(0,0,0);this.bottomLeftCorner=new u(0,0,0);this.bottomRightCorner=new u(0,0,0);this.gtpMatrix=[0,0,0,0,0,0,0,0,0];this.ptgMatrix=[0,0,0,0,0,0,0,0,0];this.ecc=new s(0,0,0);switch(n.ver){case 0:this.version=y.V1;break;case 1:default:this.version=y.V2}this.sceneId=n.id;var t=this.sceneId.toString(4);this.base4SceneId="000000000000000".substr(0,15-t.length)+t;this.productId=n.pids&&n.pids.join(",")||"";this.version===y.V2&&(this.cameraType=this._getCameraType(n.cam),n.camlla&&n.camlla.length===3&&(this.cameraLocation=new u(n.camlla[0],n.camlla[1],n.camlla[2])));this.cLook=this._getHeading(n.clook);this.look=n.look;this.focalLength=n.fl;this.frameNumber=n.fra;n.size&&n.size.length===2&&n.osize&&n.osize.length===2&&(this.width=n.size[0],this.height=n.size[1],this.originalWidth=n.osize[0],this.originalHeight=n.osize[1],this.imageScaleFactor=this.width/this.originalWidth);this.endingZoomLevel=Math.min(22,18+Math.ceil(h.log2(Math.max(this.width/512,this.height/512)))-1);this.maxNumXTiles=Math.ceil(this.width/512);this.maxNumYTiles=Math.ceil(this.height/512);n.ullla&&n.ullla.length===3&&n.urlla&&n.urlla.length===3&&n.lllla&&n.lllla.length===3&&n.lrlla&&n.lrlla.length===3&&(this.topLeftCorner=new u(n.ullla[0],n.ullla[1],n.ullla[2]),this.topRightCorner=new u(n.urlla[0],n.urlla[1],n.urlla[2]),this.bottomLeftCorner=new u(n.lllla[0],n.lllla[1],n.lllla[2]),this.bottomRightCorner=new u(n.lrlla[0],n.lrlla[1],n.lrlla[2]));this.avgAltitude=(this.topLeftCorner.altitude+this.topRightCorner.altitude+this.bottomLeftCorner.altitude+this.bottomRightCorner.altitude)/4;this.centerLocation=new u(n.la,n.lo,n.al);this.gtpMatrix=n.gtp;this.ptgMatrix=n.ptg;n.ecc&&n.ecc.length===3&&(this.ecc=new s(n.ecc[0],n.ecc[1],n.ecc[2]));this.maxTileOffset=(Math.pow(2,this.endingZoomLevel)-Math.pow(2,this.endingZoomLevel-17))/2;this.minScale=this._calculateMinScale();this.version===y.V2&&(this.altitudeScaleFactor=this.ecc.z/this.cameraLocation.altitude,this.rawSceneWidth=this.originalWidth,this.sceneWidthOffset=0,this.cameraType!==5&&this.cameraType!==6&&this.originalWidth===6870&&(this.rawSceneWidth=13450,(this.cameraType===2||this.cameraType===3)&&(this.sceneWidthOffset=this.rawSceneWidth-this.originalWidth)));this._v1PixelOffsetX=0;this._v1PixelOffsetY=0;this._calculatePixelOffset()}return n.prototype.projectToXY=function(n,t){var s=[],f,r,i=this.gtpMatrix,l,e;if(this.version===y.V2){var c=this._latLongtoEcc(n,t),u=[-(c[0]-this.ecc.x),c[1]-this.ecc.y,c[2]-this.ecc.z],o=[i[0]*u[2]+i[1]*u[0]+i[2]*u[1],i[3]*u[2]+i[4]*u[0]+i[5]*u[1],i[6]*u[2]+i[7]*u[0]+i[8]*u[1]];f=o[0]/o[1]*this.focalLength;r=-(o[2]/o[1]*this.focalLength);f=this.rawSceneWidth/2+f-this.sceneWidthOffset;r=this.originalHeight/2+r;f*=this.imageScaleFactor;r*=this.imageScaleFactor;r=this.height-r;s=[f,r]}else this.version===y.V1&&(l=[[t],[n],[1]],e=h.matrixMultiply([[i[0],i[1],i[2]],[i[3],i[4],i[5]],[i[6],i[7],i[8]]],l),f=e[0][0]/e[2][0],r=e[1][0]/e[2][0],s=[f+this._v1PixelOffsetX,r+this._v1PixelOffsetY]);return s},n.prototype.projectToLatLong=function(n,t){var l=[];if(this.version===y.V2){t=this.height-t;n/=this.imageScaleFactor;t/=this.imageScaleFactor;n=n+this.sceneWidthOffset-this.rawSceneWidth/2;t=t-this.originalHeight/2;var e=n,o=t,r=this.focalLength,i=this.gtpMatrix,u=this.ecc,d=this._getCurrentAltitude()*this.altitudeScaleFactor,s=d-u.z,a=r*i[1]-e*i[4],v=e*i[5]-r*i[2],b=r*s*i[0]+r*i[1]*u.x-r*i[2]*u.y-e*s*i[3]-e*u.x*i[4]+e*u.y*i[5],p=-o*i[4]-r*i[7],w=o*i[5]+r*i[8],k=r*i[8]*u.y-r*s*i[6]-r*i[7]*u.x+o*i[5]*u.y-s*i[3]*o-o*i[4]*u.x,g=(b*w-v*k)/(a*w-v*p),nt=(b*p-a*k)/(v*p-a*w);l=this._eccToLatLong(g,nt)}else if(this.version===y.V1){var tt=[[n-this._v1PixelOffsetX],[t-this._v1PixelOffsetY],[1]],f=this.ptgMatrix,c=h.matrixMultiply([[f[0],f[1],f[2]],[f[3],f[4],f[5]],[f[6],f[7],f[8]]],tt),it=c[0][0]/c[2][0],rt=c[1][0]/c[2][0];l=[rt,it]}return l},n.prototype.isLocationInsideScene=function(n){var t=this.projectToXY(n.latitude,n.longitude),i=!1;return t[0]>0&&t[0]0&&t[1]l&&ha&&c20?n:this.avgAltitude},n.prototype._calculateMinScale=function(){var i=this.cLook===w.north||this.cLook===w.south,n=i?this.height:this.width,t=i?this.width:this.height,r,u,f,o;return i?(r=Math.abs(e.latitudeDegreesToMeters(this.topLeftCorner.latitude)-e.latitudeDegreesToMeters(this.bottomLeftCorner.latitude))/n,u=Math.abs(e.latitudeDegreesToMeters(this.topRightCorner.latitude)-e.latitudeDegreesToMeters(this.bottomRightCorner.latitude))/n,f=Math.abs(e.longitudeDegreesToMeters(this.topLeftCorner.longitude)-e.longitudeDegreesToMeters(this.topRightCorner.longitude))/t,o=Math.abs(e.longitudeDegreesToMeters(this.bottomLeftCorner.longitude)-e.longitudeDegreesToMeters(this.bottomRightCorner.longitude))/t):(r=Math.abs(e.latitudeDegreesToMeters(this.topRightCorner.latitude)-e.latitudeDegreesToMeters(this.topLeftCorner.latitude))/n,u=Math.abs(e.latitudeDegreesToMeters(this.bottomRightCorner.latitude)-e.latitudeDegreesToMeters(this.bottomLeftCorner.latitude))/n,f=Math.abs(e.longitudeDegreesToMeters(this.bottomRightCorner.longitude)-e.longitudeDegreesToMeters(this.topRightCorner.longitude))/t,o=Math.abs(e.longitudeDegreesToMeters(this.bottomLeftCorner.longitude)-e.longitudeDegreesToMeters(this.topLeftCorner.longitude))/t),(r+u+f+o)/4},n.prototype._getHeading=function(n){var t;switch(n){case"E":t=w.east;break;case"S":t=w.south;break;case"W":t=w.west;break;case"N":default:t=w.north}return t},n.prototype._getCameraType=function(n){var t;switch(n){case 2:t=1;break;case 3:t=2;break;case 4:t=3;break;case 5:t=4;break;case 6:t=5;break;case 7:t=6;break;case 0:default:t=0}return t},n}();n.Heading=w;n.BirdseyeV2Crs=it;n.BirdseyeV2Manager=gt;n.BirdseyeV2Metadata=b;n.BirdseyeV2ImageryScene=at}catch(ni){if(n.logger)n.logger.logCriticalError(ni);else throw ni;}}).call(window)